cc = g++  
all: main cleanobj  
  
# tinyxml2的头文件目录  
TINYXML2_INCLUDE_DIR = ./config/tinyxml2  
# tinyxml2的库文件目录  
TINYXML2_LIB_DIR = ./config/tinyxml2/build  
  
# 包含tinyxml2头文件所需的编译选项  
INCLUDE_DIRS = -I$(TINYXML2_INCLUDE_DIR)  
# 链接tinyxml2库所需的链接选项  
LIB_DIRS = -L$(TINYXML2_LIB_DIR)  
  
# 所有的.o文件  
X = main.o report_state.o tsmp_send.o tsmp_rec.o init_ptp.o sync.o linkdelaymeasure.o timesync.o config.o  
  
# VPATH 仍然设置为之前的目录  
VPATH = .:./gPTP:./tsmp  
  
# 主目标  
main: $(X)  
	$(cc) $(X) -o main $(INCLUDE_DIRS) $(LIB_DIRS) -ltinyxml2 -lrt  
  
# 编译规则，确保包含tinyxml2的头文件  
%.o: %.cpp  
	$(cc) -c $< -o $@ $(INCLUDE_DIRS)  

# 清理目标  
cleanobj:    
	rm -f $(X)

